<!--#Include File="Include.asp"--><%
'--------------------------------------
'Power By 方卡在线 @2010-2014 f02
'URL:http://www.fangka.net/
'EMail:admin@ifangka.com
'QQ:861118936
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Types=Clng(Request.QueryString("Type"))

Select Case Types
	Case 1
		Call GBookSubmit() '提交留言
	Case Else
		Call FKFun.ShowErr("未发现功能项！",0)
End Select

'==========================================
'函 数 名：GBookSubmit()
'作    用：提交留言
'==========================================
Sub GBookSubmit()
	Dim FormStr,MinStr,MaxStr
	Dim Fk_GBook_Title,Fk_GBook_Content
	Dim Fk_Model_GoUrl,Fk_Model_Succeed,Fk_Model_Repeat,Fk_Model_NoTrash,Fk_Model_TrashPint,Fk_Model_MinStr,Fk_Model_MaxStr,Fk_Model_Captchas
	Dim Field_Name,Field_Label,Field_StrMin,Field_StrMax
	Dim CheckTrashStr
	Dim EMail_Address,EMail_Accouns,EMail_Pwd,EMail_Smtp,EMail_To,EMailTitle,EMailBody
	
	If Not FKFun.IsObjInstalled("JMail.Message") Then
		Fk_Site_EMail=0
	End If
	
	Id=Trim(Request.Form("Fk_GBook_Module"))
	Call FKFun.AlertNum(Id,"参数错误！")

	Sqlstr="Select Fk_Module_GBookReply,Fk_Module_Model From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_Type=3 And Fk_Module_Id=" & Id
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		ModuleGBookReply=Rs("Fk_Module_GBookReply")
		ModelId=Rs("Fk_Module_Model")
	Else
		Rs.Close
		Call FKFun.AlertInfo("未找到相应栏目！",1)
	End If
	Rs.Close
	
	Sqlstr="Select Fk_Model_Field From [Fk_Model] Where Fk_Model_Id=" & ModelId
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		ModelField=Rs("Fk_Model_Field")
	Else
		Rs.Close
		Call FKFun.AlertInfo("模型不存在！",1)
	End If
	Rs.Close
	
	Fk_Model_GoUrl=FKFun.GetSub(ModelField,"Field_GoUrl:","|;|","")
	Fk_Model_Succeed=FKFun.GetSub(ModelField,"Field_Succeed:","|;|","")
	Fk_Model_Repeat=FKFun.GetSub(ModelField,"Field_Repeat:","|;|","")
	Fk_Model_NoTrash=Clng(FKFun.GetSub(ModelField,"Field_NoTrash:","|;|",""))
	Fk_Model_TrashPint=FKFun.GetSub(ModelField,"Field_TrashPint:","|;|","")
	Fk_Model_MinStr=FKFun.GetSub(ModelField,"Field_MinStr:","|;|","")
	Fk_Model_MaxStr=FKFun.GetSub(ModelField,"Field_MaxStr:","|;|","")
	Fk_Model_Captchas=FKFun.GetSub(ModelField,"Field_Captchas:","|;|","1")
	
	'转向链接
	If Fk_Model_GoUrl="{$SiteDir$}" Then
		Fk_Model_GoUrl=SiteDir
	End If
	
	'验证码
	If Fk_Model_Captchas="1" Then
		If Request.Form("VerifyCode")<>Session("VerifyCode") Then
			Call FKFun.AlertInfo("验证码错误！",1)
		End If
	End If
	
	CheckTrashStr=""
	TempArr=Split(Split(ModelField,"|GModelOption|")(1),"|FieldList|")
	i=1
	For Each Temp In TempArr
		If Temp<>"" Then
			Field_Name=FKFun.GetSub(Temp,"Field_Name:","|;|","")
			Field_Label=FKFun.GetSub(Temp,"Field_Label:","|;|","")
			Field_StrMin=Clng(FKFun.GetSub(Temp,"Field_StrMin:","|;|",""))
			Field_StrMax=Clng(FKFun.GetSub(Temp,"Field_StrMax:","|;|",""))
			FormStr=FKFun.HTMLEncode(Trim(Request.Form(Field_Label)))
			MinStr=Replace(Fk_Model_MinStr,"{$留言条目$}",Field_Name)
			MaxStr=Replace(Fk_Model_MaxStr,"{$留言条目$}",Field_Name)
			MaxStr=Replace(MaxStr,"{$留言长度$}",Field_StrMax)
			Call FKFun.AlertString(FormStr,Field_StrMin,Field_StrMax,0,MinStr,MaxStr)
			FormStr=Replace(FormStr,Field_Label&"|:|",Field_Label&":")
			FormStr=Replace(FormStr,"|;|",";")
			CheckTrashStr=CheckTrashStr&FormStr
			Fk_GBook_Content=Fk_GBook_Content&Field_Label&"|:|"&FormStr&"|;|"
			EMailBody=EMailBody&"<p>"&Field_Name&"："&FormStr&"</p>"
			If i=1 Then
				Fk_GBook_Title=FormStr
			End If
			i=i+1
		End If
	Next
	EMailBody=EMailBody&"<p>时间："&Now()&"</p>"
	
	'屏蔽中文数量少于10%的留言
	If Fk_Model_NoTrash=1 Then
		Temp=(FKFun.StringLength(CheckTrashStr)-Len(CheckTrashStr))/Len(CheckTrashStr)
		If Temp<0.1 Then
			Call FKFun.AlertInfo(Fk_Model_TrashPint,1)
		End If
	End If
	
	'屏蔽网址大于3个的留言
	If Fk_Model_NoTrash=1 Or Fk_Model_NoTrash=2 Then
		Temp=Clng(((Len(CheckTrashStr)-Len(Replace(CheckTrashStr,"http://","")))/7))
		If Temp>3 Then
			Call FKFun.AlertInfo(Fk_Model_TrashPint,1)
		End If
	End If
	
	Sqlstr="Select Fk_GBook_Id,Fk_GBook_Title,Fk_GBook_Content,Fk_GBook_Show,Fk_GBook_Module,Fk_GBook_Ip,Fk_GBook_Time,Fk_GBook_ReAdmin From [Fk_GBook] Where Fk_GBook_Title='"&Fk_GBook_Title&"' And Fk_GBook_Module="&Id&" And Fk_GBook_Ip='"&Request.ServerVariables("REMOTE_ADDR")&"'"
	Rs.Open Sqlstr,Conn,1,3
	If Rs.Eof Then
		Application.Lock()
		Rs.AddNew()
		Rs("Fk_GBook_Title")=Fk_GBook_Title
		Rs("Fk_GBook_Content")=Fk_GBook_Content
		Rs("Fk_GBook_Show")=1
		Rs("Fk_GBook_Module")=Id
		Rs("Fk_GBook_Ip")=Request.ServerVariables("REMOTE_ADDR")
		Rs("Fk_GBook_Time")=Now()
		Rs("Fk_GBook_ReAdmin")=0
		Rs.Update()
		If Fk_Site_Html=2 And (ModuleGBookReply=0 Or ModuleGBookReply=2) Then
			Sqlstr="Update [Fk_Module] Set Fk_Module_ToHtml=1 Where Fk_Module_Id=" & Id
			Conn.Execute(Sqlstr)
		End If
		Application.UnLock()
	Else
		Rs.Close
		Call FKFun.AlertInfo(Fk_Model_Repeat,1)
	End If
	Rs.Close
	'发送留言邮件
	If Fk_Site_EMail=1 Then
		EMail_Address=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Address:","|;|","")
		EMail_Accouns=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Accouns:","|;|","")
		EMail_Pwd=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Pwd:","|;|","")
		EMail_Smtp=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Smtp:","|;|","")
		EMail_To=FKFun.GetSub(Fk_Site_EMailOption,"EMail_To:","|;|","")
		EMailTitle="“"&Fk_Site_Name&"”新信息提醒"
		Call FKFun.SendMail(EMailTitle,EMailBody,EMail_Address,EMail_Accouns,EMail_Pwd,EMail_Smtp,EMail_To)
	End If
	Call FKFun.AlertInfo(Fk_Model_Succeed,Fk_Model_GoUrl)
End Sub

Call FKFun.PageEnd()
%>